package com.situ.day8;

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class FlowLayoutDemo {
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setTitle("Hello  FLowLayout");
		JPanel panel = new JPanel();
		frame.add(panel);
		//FlowLayout默认是居中显示的，可以设置向左或向右对齐
		panel.setLayout(new FlowLayout(FlowLayout.LEFT));
		//创建组件
		JButton button1 = new JButton("张三");
		JButton button2 = new JButton("李四");
		JButton button3 = new JButton("王五");
		JButton button4 = new JButton("赵六");
		JButton button5 = new JButton("小李");
		JButton button6 = new JButton("小强");
		//添加组件
		panel.add(button1);
		panel.add(button2);
		panel.add(button3);
		panel.add(button4);
		panel.add(button5);
		panel.add(button6);
		
		//设置大小
		//width the new width of this component in pixels
		frame.setSize(500, 400);
		//设置初始位置
		frame.setLocation(500, 200);
		//关闭应用程序（设置frame默认关闭的操作，就是关闭时候退出整个应用）
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//默认是不显示
		frame.setVisible(true);
	}
}
